﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.ModelInterface;
using QLBH.DataModel;
using QLBH.Model.Controller;

namespace QLBH.FeatureModel
{
    public class PCK_MatHangModel:IPCK_MatHangModel
    {
        private Guid mhid;
        private String mhcode;
        private String tenmh;
        private int soluong;

        public Guid MHID
        {
            get
            {
                return mhid;
            }
            set
            {
                mhid = value;
            }
        }

        public string MHCODE
        {
            get
            {
                return mhcode;
            }
            set
            {
                mhcode = value;
            }
        }

        public string TENMH
        {
            get
            {
                return tenmh;
            }
            set
            {
                tenmh = value;
            }
        }

        public int SOLUONG
        {
            get
            {
                return soluong;
            }
            set
            {
                soluong = value;
            }
        }

        public void InitFromEntity(DataModel.PHIEUCHUYENKHOCT entity)
        {
            mhid = entity.MHID;

            MATHANG mh = MatHangController.GetInstance().FindBy(e => e.MHID == mhid).FirstOrDefault();

            if (mh!=null)
            {
                mhcode = mh.MHCODE;
                tenmh = mh.MHTEN;                
            }
        }

        public DataModel.PHIEUCHUYENKHOCT ToEntity()
        {
            PHIEUCHUYENKHOCT entity = new PHIEUCHUYENKHOCT();
            entity.MHID = mhid;
            entity.SOLUONG = soluong;

            return entity;
                
        }
    }
}
